import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

import Index from './views/index_1.vue'
import Login from './views/login/index_1.vue'
import Dashboard from './views/dashboard/index_1'
import MenuConfig from './views/menu/index_1'
import RoleConfig from './views/role'
import Event from './views/event'
import EventInfo from './views/eventInfo'

import InterfaceList from './views/config/interfaceList'
import ApiList from './views/api/list'
import ApiCreate from './views/api/create'


Vue.use(Router)

let r = new Router({
    routes: [
        {
            path: '/',
            name: 'index',
            component: Index,
            children : [
                {
                    name : 'dashboard',
                    path: '/dashboard',
                    component: Dashboard,
                    meta: {
                        title:"首页",
                    }
                },
                {
                    name : 'menuConfig',
                    path: '/menuConfig',
                    component: MenuConfig,
                    meta: {
                        title:"设置菜单",
                    }
                },
                {
                    name : 'roleconfig',
                    path: '/roleconfig',
                    component: RoleConfig,
                    meta: {
                        title:"设置角色",
                    }
                },

                {
                    path: '/interfacelist.html',
                    name: 'synclist',
                    component: InterfaceList,
                    meta: {
                        title:"同步接口",
                    }
                },

                {
                    path: '/event.html',
                    name: 'event',
                    component: Event,
                    meta: {
                        title:"事件列表",
                    }
                },

                {
                    path: '/eventinfo.html',
                    name: 'eventinfo',
                    component: EventInfo,
                    meta: {
                        title:"事件详情",
                    }
                },

                {
                    path: '/apilist.html',
                    name: 'apilist',
                    component: ApiList,
                    meta: {
                        title:"接口列表",
                    }
                },
                {
                    path: '/apicreate.html',
                    name: 'apicreate',
                    component: ApiCreate,
                    meta: {
                        title:"创建接口",
                    }
                },

                {
                    path: '/map',
                    name: 'map',
                    component: () => import('./views/map/index1.vue'),
                    meta: {
                        title:"首页",
                    }
                },

                {
                    path: '/grideList',
                    name: 'grideList',
                    component: () => import('./views/gride/list.vue'),
                    meta: {
                        title:"网格列表",
                    }
                },

                {
                    path: '/createGride',
                    name: 'createGride',
                    component: () => import('./views/gride/create.vue'),
                    meta: {
                        title:"创建网格",
                    }
                },

                {
                    path: '/roleList',
                    name: 'roleList',
                    component: () => import('./views/role/list_1.vue'),
                    meta: {
                        title:"网格角色",
                    }
                },

                {
                    path: '/createRole',
                    name: 'createRole',
                    component: () => import('./views/role/create_1.vue'),
                    meta: {
                        title:"创建角色",
                    }
                },

                {
                    path: '/userList',
                    name: 'userList',
                    component: () => import('./views/user/list_1.vue'),
                    meta: {
                        title:"网格人员管理",
                    }
                },

                {
                    path: '/createUser',
                    name: 'createUser',
                    component: () => import('./views/user/create.vue'),
                    meta: {
                        title:"创建角色",
                    }
                },


                {
                    path: '/createMessage',
                    name: 'createMessage',
                    component: () => import('./views/message/create.vue'),
                    meta: {
                        title:"创建消息",
                    }
                },

                {
                    path: '/messageList',
                    name: 'messageList',
                    component: () => import('./views/message/list_1.vue'),
                    meta: {
                        title:"消息列表",
                    }
                },

                {
                    path: '/helpList',
                    name: 'helpList',
                    component: () => import('./views/help/list_1.vue'),
                    meta: {
                        title:"帮助列表",
                    }
                },

                {
                    path: '/newsList',
                    name: 'newsList',
                    component: () => import('./views/news/list_1.vue'),
                    meta: {
                        title:"法律法规列表",
                    }
                },

                {
                    path: '/eventList',
                    name: 'eventList',
                    component: () => import('./views/event/index_1.vue'),
                    meta: {
                        title:"事件列表",
                    }
                },

                {
                    path: '/wordbookList',
                    name: 'wordbookList',
                    component: () => import('./views/wordbook/index_1.vue'),
                    meta: {
                        title:"字典列表",
                    }
                },

                {
                    path: '/onlinestatistics',
                    name: 'onlinestatistics',
                    component: () => import('./views/onlinestatistics/index_1.vue'),
                    meta: {
                        title:"人员在线历史统计",
                    }
                },

                {
                    path: '/eventstatistics',
                    name: 'eventstatistics',
                    component: () => import('./views/eventstatistics/index.vue'),
                    meta: {
                        title:"事件办理情况",
                    }
                },

                {
                    path: '/companystatistics',
                    name: 'companystatistics',
                    component: () => import('./views/companystatistics/index.vue'),
                    meta: {
                        title:"网格企业统计",
                    }
                },

                {
                    path: '/modifyPassword',
                    name: 'modifyPassword',
                    component: () => import('./views/modifypassword/index_1.vue'),
                    meta: {
                        title:"修改密码",
                    }
                },

                {
                    path: '/jixiao',
                    name: 'jixiao',
                    component: () => import('./views/jixiao/index1.vue'),
                    meta: {
                        title:"绩效",
                    }
                },

                {
                    path: '/statistics',
                    name: 'statistics',
                    component: () => import('./views/statistics/index.vue'),
                    meta: {
                        title:"统计",
                    }
                },
            ]
        },
        
        {
            path: '/login',
            name: 'login',
            component: Login,
            meta: {
                title:"网格员综合管理系统",
            }
        },

        // {
        //     path: '/ticket',
        //     name: 'ticket',
        //     component: () => import('./views/ticket/index.vue'),
        //     meta: {
        //         title:"套票发放统计",
        //     }
        // },


        // --------- 套票发放查询 ---------- //
        // {
        //     path: '/ticket1',
        //     name: 'ticket1',
        //     component: () => import('./views/ticket/index_1.vue'),
        //     meta: {
        //         title:"套票发放统计",
        //     }
        // },

        {
            path: '/carousel',
            name: 'carousel',
            component: () => import('./views/test/carousel.vue')
        },

        
    ],

    scrollBehavior (to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            return { x: 0, y: 0 }
        }
    },
})


r.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title;
    }
    next();
});


export default r;
